package org.stone.project.common.pojo.constant;

import java.util.Locale;
import java.util.TimeZone;

/**
 * 系统常量
 */
public class SysConstant {
    /**
     * UTF-8 字符集
     */
    public static final String UTF8 = "UTF-8";

    /**
     * 系统语言
     */
    public static final Locale DEFAULT_LOCALE = Locale.SIMPLIFIED_CHINESE;

    /**
     * 时间格式字符串
     */
    public static final String DATE_ALL_FORMATE = "yyyy-MM-dd HH:mm:ss.SSS";

    public static final String DATE_TIME_FORMATE = "yyyy-MM-dd HH:mm:ss";

    public static final String DATE_FORMATE = "yyyy-MM-dd";

    public static final String DATE_YEAER_MONTH_FORMATE = "yyyy-MM-dd";

    /**
     * 北京时区
     */
    public static final TimeZone gmt = TimeZone.getTimeZone("GMT+08:00");

    /**
     * 资源映射路径 前缀
     */
    public static final String RESOURCE_PREFIX = "/profile";

    /**
     * sa-token 拦截器用户信息缓存key
     */
    public static String USER_INFO = "USER_INFO";

    /**
     * 管理员角色权限标识
     */
    public static final String SUPER_ADMIN = "admin";

    /**
     * 未知
     */
    public static final String UN_KNOW = "UN_KNOW";

    /**
     * 所有权限标识
     */
    public static final String ALL_PERMISSION = "*:*:*";

    /**
     * 缓存图形验证码缓存前缀
     */
    public static final String CAPTCHA_CODE_PREFIX = "CAPTCHA_CODES_PREFIX:";

    /**
     * 用户登录失败次数 LOGIN_ERROR_NUM_COUNT_PREFIX:UserId
     */
    public static final String LOGIN_ERROR_NUM_COUNT_PREFIX = "LOGIN_ERROR_NUM_COUNT_PREFIX:";

    /**
     * 账户锁
     */
    public static final String LOGIN_LOCK_COUNT_PREFIX = "LOGIN_LOCK_COUNT_PREFIX:";

    public static final String EMPTY_STR = "";

    /**
     * 字典管理 cache key
     */
    public static final String SYS_DICT_KEY = "sys_dict:";

    /**
     * 字典管理 更新锁
     */
    public static final String SYS_DICT_LOCK_KEY = "SYS_DICT_LOCK_KEY";

    /**
     * 系统配置更新锁
     */
    public static final String SYS_CONFIG_LOCK_KEY = "SYS_CONFIG_LOCK_KEY";

    /**
     * 自动生成代码修改锁
     */
    public static final String GEN_UPDATE_LOCK_KEY = "GEN_UPDATE_LOCK_KEY";

    /**
     * 安全密码字符串
     */
    public static final String SAVE_PWD_STR = "******";

    /**
     * 参数管理 cache key
     */
    public static final String SYS_CONFIG_KEY = "sys_config:";

    /**
     * 日志数据源名称
     */
    public final static String LOG_DS_NAME = "log_ds_name";

    /**
     * 系统自动化工具
     */
    public final static String GENERATOR_DS_NAME = "generator_ds_name";

    /**
     * 请求id
     */
    public final static String REQUEST_ID = "Sys_Request_Id";

    /**
     * 文件处理对象名称
     */
    public final static String FILE_BEAN_NAME = "fileClientAdapter";

    public final static String LOG_LEVEL_INFO = "INFO";
    public final static String LOG_LEVEL_WARN = "WARN";
    public final static String LOG_LEVEL_ERR = "ERR";


    /**
     * 系统常量
     */
    public static final Integer JUST_ONE = 1;

    /**
     * 系统常量
     */
    public static final Integer JUST_ZERO = 0;

    /**
     * 系统默认
     */
    public static final String DEFAULT = "default";


    /** 菜单无操作    */
    public static final String NO_REDIRECT = "noRedirect";



    public static boolean isAdmin(String roleKey){
        return SUPER_ADMIN.equals(roleKey)?true:false;
    }



    public static String getCaptchaKey(String key){
        return CAPTCHA_CODE_PREFIX+key;
    }

    public static String getLoginErrorNumKey(String key){
        return LOGIN_ERROR_NUM_COUNT_PREFIX+key;
    }

    public static String getLoginLockKey(String key){
        return LOGIN_LOCK_COUNT_PREFIX+key;
    }
}
